﻿
Partial Class Interfaz_Principal
    Inherits System.Web.UI.Page
    Dim CL As New ControladorLogica

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'CL.Mensaje("queque")
    End Sub

    Private Function ValidaUsuario() As Boolean
        Dim UserName As String = LoginIndex.UserName()
        Dim Password As String = LoginIndex.Password()
        Dim Usuario As New Usuario(UserName, Password)
        Dim Result As Boolean = CL.ValidarUsuario(Usuario)

        If Result = True Then
            Session("user") = String.Empty
            Session("user") = Usuario.User
            Response.Redirect("Seleccion.aspx")
        Else
            Session("user") = String.Empty
            LabelAutenticacion.Text = "Usuario no existe o datos mal ingresados"
            Me.Mensaje("Usuario no existe o datos mal ingresados")
        End If

    End Function

    Protected Sub LoginIndex_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginIndex.Authenticate
        ValidaUsuario()
    End Sub

    Public Sub Mensaje(ByVal msg As String)
        Dim alertScript As String = "<script language=JavaScript runat=server>"
        alertScript &= "alert('" & msg & "');"
        alertScript &= "</script>"
        ClientScript.RegisterClientScriptBlock(Page.GetType(), "clientScrip", alertScript)
    End Sub


   
End Class
